from django.urls import path
from rest_framework import routers

from .openapi import *
from .api import ProjectViewSet, LabelList, ProjectStatsAPI, LabelDetail, RelationLabelList,RelationLabelDetail,\
    AnnotationList, AnnotationDetail, DocumentList, RelationRecommendationList,\
    AttributeLabelList,AttributeLabelDetail,AttributeAnnotationList,AttributeAnnotationDetail,AnnotationDataView,\
    DocumentDetail, RelationAnnotationList, RelationAnnotationDetail, SubmitDocs,\
    SettingList, RecommendationHistoryList, RecommendationHistoryDetail,\
    RecommendationHistoryView, DownloadView, UploadView,CsrfTokenView,UserView,\
    RecommendationsView,RelationRecommendationsView,RecommendationRuleList,RecommendationRuleDetail,AutoAnnotateView,\
    LLMView, PreSettingsList,PredictionView,TrainedModelViewSet
from .views import *

from django.views.decorators.csrf import csrf_exempt

router = routers.DefaultRouter()
router.register(r'projects', ProjectViewSet)
router.register(r'trainedmodels', TrainedModelViewSet)

urlpatterns = [
    path("openapi/getUrl",GetUrl.as_view()),
    path("openapi/autologin",csrf_exempt(AutoLogin.as_view())),
    path("openapi/register",csrf_exempt(AutoRegister.as_view())),
    path("openapi/<int:project_id>/addLabel",AddLabel.as_view()),
    path("login",csrf_exempt(Login.as_view())),
    path("logout",Logout.as_view()),
    path("user",UserView.as_view()),
    path('login_2',login_2),

    path('api/projects/<int:project_id>/docs/prediction',PredictionView.as_view()),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/LLM',LLMView.as_view()),
    path('api/projects/<int:project_id>/annotationdata',AnnotationDataView.as_view()),
    path('api/projects/<int:project_id>/autoannotate',AutoAnnotateView.as_view(),name='auto annotate the rest docs'),
    path('api/projects/<int:project_id>/stats/', ProjectStatsAPI.as_view(), name='stats-api'),
    path('api/projects/<int:project_id>/settings/', SettingList.as_view(), name='settings'),
    path('api/projects/<int:project_id>/presettings/', PreSettingsList.as_view(), name='presettings'),
    path('api/projects/<int:project_id>/history/', RecommendationHistoryList.as_view(), name='histories'),
    path('api/projects/<int:project_id>/history/<int:history_id>', RecommendationHistoryDetail.as_view(),
         name='history'),
    path('api/projects/<int:project_id>/rule/', RecommendationRuleList.as_view(), name='recommendation_rules'),
    path('api/projects/<int:project_id>/rule/<int:rule_id>', RecommendationRuleDetail.as_view(),
         name='recommendation_rule'),
    path('api/projects/<int:project_id>/labels/', LabelList.as_view(), name='labels'),
    path('api/projects/<int:project_id>/labels/<int:label_id>', LabelDetail.as_view(), name='label'),
    path('api/projects/<int:project_id>/relationLabels/', RelationLabelList.as_view(), name='relation_labels'),
    path('api/projects/<int:project_id>/relationLabels/<int:relation_id>', RelationLabelDetail.as_view(), name='relation_label'),
    path('api/projects/<int:project_id>/attributeLabels/', AttributeLabelList.as_view(),
         name='attribute_labels'),
    path('api/projects/<int:project_id>/attributeLabels/<int:attribute_id>',
         AttributeLabelDetail.as_view(), name='attribute_label'),
    path('api/projects/<int:project_id>/docs/', DocumentList.as_view(), name='docs'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>', DocumentDetail.as_view(), name='doc'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/annotations/', AnnotationList.as_view(), name='annotations'),
    path('api/projects/<int:project_id>/docs/recommendations/',RecommendationsView.as_view()),
    path('api/projects/<int:project_id>/docs/relationrecommendations/',RelationRecommendationsView.as_view()),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/relationrecommendations/',RelationRecommendationList.as_view(),
         name='relation_recommendations'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/annotations/<int:annotation_id>', AnnotationDetail.as_view(),
         name='ann'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/relationannotations/', RelationAnnotationList.as_view(),
         name='relation_annotations'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/relationannotations/<int:relation_annotation_id>',
         RelationAnnotationDetail.as_view(),name='relation_ann'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/attributeannotations/', AttributeAnnotationList.as_view(),
         name='attribute_annotations'),
    path('api/projects/<int:project_id>/docs/<int:doc_id>/attributeannotations/<int:attribute_annotation_id>',
         AttributeAnnotationDetail.as_view(),name='relation_ann'),
    path('api/projects/download/<int:project_id>/<int:user_id>/<str:type>', DownloadView.as_view(), name='download'),
    path('api/projects/upload/<int:project_id>/<int:user_id>/<str:type>',UploadView.as_view(),name='upload'),
    path('api/projects/<int:project_id>/submit',SubmitDocs.as_view()),
    path('api/token',csrf_exempt(CsrfTokenView.as_view())),
]
